package com.pers.springcloud.entities;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: 黄建
 * @Date: 2020/3/6 17:44
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class JSONResult<T> {

    private Integer code;

    private String msg;

    private T data;

    public JSONResult(Integer code,String msg){
        this(code,msg,null);
    }

    public static JSONResult success(){
        return new JSONResult(200,"ok");
    }

    public static JSONResult error(String msg){
        return new JSONResult(500,msg);
    }

    public static JSONResult<Object> success(String msg,Object data){
        return new JSONResult<>(200,msg,data);
    }

}
